home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 August: Tool Chest / Dev.CD Aug 95 TC / Dev.CD Aug 95 TC.toast / Tool Chest / Interfaces / UniversalInterfaces 2.1B1 / PInterfaces / CursorCtl.p < prev    next >
Encoding:
Text File  |  1995-04-18  |  5.5 KB  |  144 lines  |  [TEXT/MPS ]

  1. {
  2.     File:        CursorCtl.p
  3.  
  4.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a3  ETO #16, MPW prerelease. Jan 2, 1995
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. }
  16.  
  17. {$IFC UNDEFINED UsingIncludes}
  18. {$SETC UsingIncludes := 0}
  19. {$ENDC}
  20.  
  21. {$IFC NOT UsingIncludes}
  22.     UNIT CursorCtl;
  23.     INTERFACE
  24. {$ENDC}
  25.  
  26. {$IFC UNDEFINED __USINGCURSORCTL__}
  27. {$SETC __USINGCURSORCTL__ := 1}
  28.  
  29. {$PUSH}
  30. {$ALIGN MAC68K}
  31. {$IFC UNDEFINED __CFM68K__}
  32.     {$LibExport+}
  33. {$ENDC}
  34.  
  35. TYPE
  36.  
  37. { Kinds of cursor supported by CursorCtl }
  38. Cursors = (HIDDEN_CURSOR,I_BEAM_CURSOR,CROSS_CURSOR,PLUS_CURSOR,WATCH_CURSOR,
  39.     ARROW_CURSOR);
  40.  
  41. acurPtr = ^Acur;
  42. acurHandle = ^acurPtr;
  43. Acur = RECORD
  44.     n: INTEGER;         {Number of cursors ("frames of film")}
  45.     index: INTEGER;     { Next frame to show <for internal use>}
  46.     frame1: INTEGER;    {'CURS' resource id for frame #1}
  47.     fill1: INTEGER;     {<for internal use>}
  48.     frame2: INTEGER;    {'CURS' resource id for frame #2}
  49.     fill2: INTEGER;     {<for internal use>}
  50.     frameN: INTEGER;    {'CURS' resource id for frame #N}
  51.     fillN: INTEGER;     {<for internal use>}
  52.     END;
  53.  
  54.  
  55.  
  56. PROCEDURE InitCursorCtl(newCursors: UNIV acurHandle);
  57. { Initialize the CursorCtl unit. This should be called once prior to calling
  58. RotateCursor or SpinCursor. It need not be called if only Hide_Cursor or
  59. Show_Cursor are used. If NewCursors is NULL, InitCursorCtl loads in the
  60. 'acur' resource and the 'CURS' resources specified by the 'acur' resource
  61. ids.  If any of the resources cannot be loaded, the cursor will not be
  62. changed.
  63.  
  64. The 'acur' resource is assumed to either be in the currently running tool or
  65. application, or the MPW Shell for a tool, or in the System file.  The 'acur'
  66. resource id must be 0 for a tool or application, 1 for the Shell, and 2 for
  67. the System file.
  68.  
  69. If NewCursors is not NULL, it is ASSUMED to be a handle to an 'acur' formatted
  70. resource designated by the caller and it will be used instead of doing a
  71. GetResource on 'acur'. Note, if RotateCursor or SpinCursor are called without
  72. calling InitCursorCtl, then RotateCursor and SpinCursor will do the call for
  73. the user the first time it is called.  However, the possible disadvantage of
  74. using this technique is that the resource memory allocated may have
  75. undesirable affect (fragmentation?) on the application. Using InitCursorCtl
  76. has the advantage of causing the allocation at a specific time determined by
  77. the user.
  78.  
  79. Caution: InitCursorCtl MODIFIES the 'acur' resource in memory.    Specifically,
  80. it changes each FrameN/fillN integer pair to a handle to the corresponding
  81. 'CURS' resource also in memory.  Thus if NewCursors is not NULL when
  82. InitCursorCtl is called, the caller must guarantee NewCursors always points to
  83. a "fresh" copy of an 'acur' resource.  This need only be of concern to a
  84. caller who wants to repeatly use multiple 'acur' resources during execution of
  85. their programs.
  86.  }
  87.  
  88. PROCEDURE RotateCursor(counter: LONGINT);
  89. { RotateCursor is called to rotate the "I am active" "beach ball" cursor, or to
  90. animate whatever sequence of cursors set up by InitCursorCtl. The next cursor
  91. ("frame") is used when Counter % 32 = 0 (Counter is some kind of incrementing
  92. or decrementing index maintained by the caller). A positive counter sequences
  93. forward through the cursors (e.g., it rotates the "beach ball" cursor
  94. clockwise), and a negative cursor sequences through the cursors backwards
  95. (e.g., it rotates the "beach ball" cursor counterclockwise).  Note,
  96. RotateCursor just does a Mac SetCursor call for the proper cursor picture.
  97.   It is assumed the cursor is visible from a prior Show_Cursor call.
  98.  }
  99.  
  100. PROCEDURE SpinCursor(increment: INTEGER);
  101. { SpinCursor is similar in function to RotateCursor, except that instead of
  102. passing a counter, an Increment is passed an added to a counter maintained
  103. here.  SpinCursor is provided for those users who do not happen to have a
  104. convenient counter handy but still want to use the spinning "beach ball"
  105. cursor, or any sequence of cursors set up by InitCursorCtl.  A positive 
  106. increment sequences forward through the curos (rotating the "beach ball"
  107. cursor clockwise), and a negative increment sequences backward through the
  108. cursors (rotating the "beach ball" cursor counter-clockwise).  A zero value
  109. for the increment resets the counter to zero.  Note, it is the increment, and
  110. not the value of the counter that determines the sequencing direction of the
  111. cursor (and hence the spin direction of the "beach ball" cursor).
  112.  }
  113.  
  114. PROCEDURE Hide_Cursor;
  115. { Hide the cursor if it is showing.This is this unit's call to the Mac
  116. HideCursor routine.Thus the Mac cursor level is decremented by one when this
  117. routine is called.
  118.  }
  119.  
  120. PROCEDURE Show_Cursor(cursorKind: Cursors);
  121. { Increment the cursor level, which may have been decremented by Hide_Cursor,
  122. and display the specified cursor if the level becomes 0 (it is never
  123. incremented beyond 0).The CursorKind is the kind of cursor to show.  It is
  124. one of the values HIDDEN_CURSOR, I_BEAM_CURSOR, CROSS_CURSOR, PLUS_CURSOR,
  125. WATCH_CURSOR, and ARROW_CURSOR. Except for HIDDEN_CURSOR, a Mac SetCursor is
  126. done for the specified cursor prior to doing a ShowCursor.    HIDDEN_CURSOR just
  127. causes a ShowCursor call.  Note, ARROW_CURSOR will only work correctly if
  128. there is already a grafPort set up pointed to by 0(A5).
  129.  }
  130.  
  131.  
  132. {$IFC UNDEFINED __CFM68K__}
  133.     {$LibExport-}
  134. {$ENDC}
  135. {$ALIGN RESET}
  136. {$POP}
  137.  
  138. {$ENDC}    { __USINGCURSORCTL__ }
  139.  
  140. {$IFC NOT UsingIncludes}
  141.     END.
  142. {$ENDC}
  143.  
  144.